<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>json数据转换与本地存储</title>
    <script src="../angular.js"></script>
</head>
<body>
    <div ng-app="gg" ng-controller="ctrl">
    {{data.name}}
    </div>

    <script>
        var mod = angular.module('gg', []);

        mod.controller('ctrl', ['$scope', function($scope) {
            // body...
            /*
            *localStorage.getItem 从本地存储读取
            *angular.fromJson 将json字符串转为json对象
            */
           $scope.data = angular.fromJson( localStorage.getItem('data'));
        }])
    </script>
</body>
</html>